<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page import="org.apache.ibatis.session.SqlSession"%>
<%@page import="com.penta.mybatis.SqlSessionManager"%>
<%@page import="java.util.Enumeration"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    
<%

	// 데이터베이스 연결 및 <키,값> 출력

	Enumeration param1 = request.getParameterNames();

	Map item = new HashMap();
	
	int updateCnt =0;
	String sOpser="";

	while (param1.hasMoreElements() )
	{
		String paramKey = param1.nextElement().toString();
	
		System.out.println("KEY = " + paramKey + " >>> " + "VALUE : " + request.getParameter(paramKey)  );
	
		item.put(paramKey, request.getParameter(paramKey));
	}
	System.out.println("쿼리 시작전");
	sOpser = request.getParameter("oper");
	System.out.println("oper 값 = " +sOpser);
	
	//System.out.println(request.getParameter("oper"));

	SqlSession query = SqlSessionManager.getSqlSessionFactory().openSession();

	// add
	if(sOpser.equals("add"))
	{
		updateCnt = query.insert("role.insertA", item);
		query.commit();
		query.close();
	}
	// edit
	else if(sOpser.equals("edit"))
	{
		updateCnt = query.update("role.updateA", item);
		query.commit();
		query.close();
	}
	else if(sOpser.equals("del"))
	{
		updateCnt = query.update("role.deleteA", item);
		query.commit();
		query.close();
	}
	else{
		System.out.println("query error");
	}
	System.out.println("Updata row count = " + updateCnt);
%>




